<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-3.2.1.min.js">
	//alert("x");
</script>

<script type="text/javascript">
	function sendAjax(){
		// application/x-www-form-urlencoded;charset=UTF-8 默认
		
	}

	//页面加载完毕自动调用
	 $(function(){
		 var a ="username=张三";   //y
		 var b  ="{username:张三}"
		 
		 $.ajax({
				url:"${pageContext.request.contextPath }/area/xx.do",
				type:"post",
				/* data:'parentid=0',   */
				data:{parentid:0},
				dataType:"json", /* 期待响应 */
				success:function(data){
					//找到
					var $pro = $("#pro");
					//变量
					$.each(data,function(index,dom){
						$pro.append("<option value="+data[index].codeid+" >"+data[index].cityname+" </option>");
					});
				}
			});
	}); 
	
	
	function  sendJson() {
		$.ajax({
			url:"${pageContext.request.contextPath }/area/xx.do",
			type:"post",
			data:'{"parentid":0}',  /* 标准的json */
			contentType:"application/json", /* 浏览器发送请求的是json 移动端 */
			dataType:"json", /* 期待响应 */
			success:function(data){
				alert(data);
				alert(data.length);
			}
		});   
	}
	
	//
	function  b(v) {
		alert(v.value);
		$.ajax({
			url:"${pageContext.request.contextPath }/area/xx.do",
			type:"post",
			data:"parentid="+v.value ,  /* 标准的json */
			dataType:"json", /* 期待响应 */
			success:function(data){
				alert(data);
				alert(data.length);
			}
		});   
	}
</script>

</head>  
<body>

<form action="">

	<select id="pro" onchange="b(this)"></select>省 </br>
	
	<select id="city" ></select>市</br>
	
	<select id="area"></select>区 </br>

</form>
  
<button onclick="sendAjax()">发送ajax  </button>

</body>
</html>